#include <iostream>
#include <fstream>

#include "ClassService.h"
#include "CourseSelectionService.h"
#include "CourseService.h"
#include "CourseTimeService.h"
#include "StudentScoreService.h"
#include "StudentService.h"
#include "User.h"

using namespace std;

void studentManagerMenu();
void courseManagerMenu();
void courseSelectionManagerMenu();
void studentScoreManagerMenu();
void classManagerMenu();


int main() {

    int choice = 0;
    while (true){
        cout << "\t+--------教务信息管理系统-------+" << endl;
        cout << "\t|\t\t\t\t|" << endl;
        cout << "\t|\t1.学生管理功能\t\t|" << endl;
        cout << "\t|\t2.课程管理功能\t\t|" << endl;
        cout << "\t|\t3.学生选课管理功能\t|" << endl;
        cout << "\t|\t4.学生成绩管理功能\t|" << endl;
        cout << "\t|\t5.班级管理功能\t\t|" << endl;
        cout << "\t|\t\t\t\t|" << endl;
        cout << "\t+-------------------------------+" << endl;
        cout << "\n\n\t请输入要进行的操作(输入0退出程序):";
        cin>>choice;
        switch (choice) {
            case 0:
                cout<<"欢迎下次使用"<<endl;
                system("pause");
                return 0;
            case 1:
                cout<<"进入学生管理界面"<<endl;
                system("pause");
                system("cls");
                studentManagerMenu();
                break;
            case 2:
                cout<<"进入课程管理界面"<<endl;
                system("pause");
                system("cls");
                courseManagerMenu();
                break;
            case 3:
                cout<<"进入学生选课界面"<<endl;
                system("pause");
                system("cls");
                courseSelectionManagerMenu();
                break;
            case 4:
                cout<<"进入学生成绩管理界面"<<endl;
                system("pause");
                system("cls");
                studentScoreManagerMenu();
                break;
            case 5:
                cout<<"进入班级管理界面"<<endl;
                system("pause");
                system("cls");
                classManagerMenu();
                break;
            default:
                cout<<"输入有误，请重新选择！"<<endl;
                system("pause");
                system("cls");
                break;


        }
    }



}

void studentManagerMenu(){
    StudentService studentService;
    int choice = 0;
    while(true){
        cout<<"\t\t1.查看学生信息\t\t"<<endl;
        cout<<"\t\t2.录入学生信息\t\t"<<endl;
        cout<<"\t\t3.按课程统计学生名单\t\t"<<endl;
        cout<<"\t\t4.查看学生学业进程表\t\t"<<endl;

        cout<<"请输入你的选择(输入0返回到上层目录):";
        cin>>choice;
        switch (choice) {
            case 0:{
                cout<<"返回到上层目录"<<endl;
                system("pause");
                system("cls");
                return;

            }

            case 1:{
                cout<<"查看所有学生信息"<<endl;
                studentService.showAllStudentList();
                system("pause");
                system("cls");
                break;
            }

            case 2:{
                cout<<"批量插入学生信息："<<endl;
                studentService.batchInsertStudent();
                break;
            }

            case 3:{
                cout<<"按课程统计学生名单:"<<endl;
                string courseId;
                cout<<"请输入课程编号";
                cin>>courseId;
                studentService.showStudentListByCourse(courseId);
                system("pause");
                system("cls");
                break;
            }
            case 4:{
                cout<<"查看学生学业进程表:"<<endl;
                string studentId;
                cout<<"请输入要查看的学生编号:";
                cin>>studentId;
                studentService.showStudentProgressChart(studentId);
                system("pause");
                system("cls");
                break;

            }

            default:{
                cout<<"输入有误，请重新选择！"<<endl;
                system("pause");
                system("cls");
                break;
            }

        }


    }

}

void courseManagerMenu() {
    CourseService courseService;
    int choice = 0;
    while (true){
        cout<<"\t\t1.查看课程信息\t\t"<<endl;
        cout<<"\t\t2.录入课程信息\t\t"<<endl;
        cout<<"\t\t3.按单词组合查询课程名\t\t"<<endl;
        cout<<"请输入你的选择(输入0返回到上层目录):";
        cin>>choice;
        switch (choice) {
            case 0:{
                cout<<"返回到上层目录"<<endl;
                system("pause");
                system("cls");
                return;
            }

            case 1:{
                cout<<"查看所有课程信息"<<endl;
                courseService.showAllCourseList();
                system("pause");
                system("cls");
                break;
            }

            case 2:{
                courseService.batchInsertCourse();
                system("pause");
                system("cls");
                break;
            }
            case 3:{
                courseService.matchCourseByInput();
                system("pause");
                system("cls");
                break;
            }

            default:{
                cout<<"输入有误，请重新选择！"<<endl;
                system("pause");
                system("cls");
                break;
            }
        }
    }
}
void courseSelectionManagerMenu() {
    CourseSelectionService courseSelectionService;
    int choice = 0;
    while(true){
        cout<<"\t\t1.查看选课信息\t\t"<<endl;
        cout<<"\t\t2.批量录入课程信息\t\t"<<endl;
        cout<<"\t\t3.按班统计学生选课情况\t\t"<<endl;
        cout<<"请输入你的选择(输入0返回到上层目录):";
        cin>>choice;
        switch (choice) {
            case 0:{
                cout<<"返回到上层目录"<<endl;
                system("pause");
                system("cls");
                return;
            }
            case 1:{
                cout<<"查看所有选课信息"<<endl;
                courseSelectionService.showAllCourseSelectionList();
                break;
            }
            case 2:{
                cout<<"批量插入选课信息"<<endl;
                courseSelectionService.batchInsertCourseSelection();
                break;
            }
            case 3:{
                string classId;
                cout<<"按班统计学生选课情况"<<endl;
                cout<<"请输入班级id:";
                cin>>classId;
                courseSelectionService.showCourseSelectionByClass(classId);
                break;


            }
            default:{
                cout<<"输入有误，请重新选择！"<<endl;
                system("pause");
                system("cls");
                break;

            }

        }

    }



}

void studentScoreManagerMenu() {
    StudentScoreService studentScoreService;
    int choice = 0;
    while(true){
        cout<<"\t\t1.查看所有成绩信息\t\t"<<endl;
        cout<<"\t\t2.批量录入成绩信息\t\t"<<endl;
        cout<<"\t\t3.按班统计学生考试成绩\t\t"<<endl;
        cout<<"\t\t4.按课程统计学生考试成绩\t\t"<<endl;
        cout<<"请输入你的选择(输入0返回到上层目录):";
        cin>>choice;
        switch (choice) {
            case 0:{
                cout<<"返回到上层目录"<<endl;
                system("pause");
                system("cls");
                return;
            }
            case 1:{
                cout<<"查看所有成绩信息"<<endl;
                studentScoreService.showAllStudentScoreList();
                system("pause");
                system("cls");
                break;
            }
            case 2:{
                cout<<"批量插入成绩信息"<<endl;
                studentScoreService.batchInsertStudentScore();
                break;
            }
            case 3:{
                cout<<"按班统计学生考试成绩"<<endl;
                string classId;
                cout<<"请输入班级编号:";
                cin>> classId;
                studentScoreService.showStudentScoreByClass(classId);
                system("pause");
                system("cls");
                break;
            }
            case 4:{
                cout<<"按课程统计学生考试成绩:"<<endl;
                string courseId;
                cout<<"请输入课程编号:";
                cin>>courseId;
                studentScoreService.showStudentScoreByCourse(courseId);
                system("pause");
                system("cls");
                break;

            }
            default:{
                cout<<"输入有误，请重新选择！"<<endl;
                system("pause");
                system("cls");
                break;

            }

        }

    }


}

void classManagerMenu() {
    ClassService classService;
    int choice = 0;
    while(true){
        cout<<"\t\t1.查看所有班级信息\t\t"<<endl;
        cout<<"\t\t2.批量录入班级信息\t\t"<<endl;
        cout<<"请输入你的选择(输入0返回到上层目录):";
        cin>>choice;
        switch (choice) {
            case 0:{
                cout<<"返回到上层目录"<<endl;
                system("pause");
                system("cls");
                return;
            }
            case 1:{
                cout<<"查看所有班级信息"<<endl;
                classService.showAllClassList();
                system("pause");
                system("cls");
                break;
            }
            case 2:{
                cout<<"批量插入成绩信息"<<endl;
                classService.batchInsertClass();
                system("pause");
                system("cls");
                break;
            }
            default:{
                cout<<"输入有误，请重新选择！"<<endl;
                system("pause");
                system("cls");
                break;

            }

        }

    }

}
